<template>
  <div :class="wrpCls">
<!--    <avatar-dropdown :menu="showMenu" :current-user="currentUser" :class="prefixCls" />-->
<!--    <select-lang :class="prefixCls" />-->
    <span class="ant-pro-account-avatar" style="float: right">
      <a-avatar size="small" :src="currentUser.imagePath" class="antd-pro-global-header-index-avatar" />
      <span style="margin:0 10px">{{ currentUser.name }}</span>
      <span style="margin:0 10px;cursor: pointer" @click="handleLogout">退出登录</span>
    </span>
  </div>
</template>

<script>
import { getUserThumbAvatar, logout } from '@/api/avatarDropdown'
import AvatarDropdown from './AvatarDropdown'
import SelectLang from '@/components/SelectLang'
import storage from 'store'
import { Modal } from 'ant-design-vue'

export default {
  name: 'RightContent',
  data () {
    return {
      showMenu: true,
        currentUser: {}
    }
  },
  components: {
    AvatarDropdown,
    SelectLang
  },
  props: {
    handleFunction: Function,
    collapsed: Boolean,
    prefixCls: {
      type: String,
      default: 'ant-pro-global-header-index-action'
    },
    isMobile: {
      type: Boolean,
      default: () => false
    },
    topMenu: {
      type: Boolean,
      required: true
    },
    theme: {
      type: String,
      required: true
    }
  },
  data () {
    return {
      showMenu: true,
      currentUser: {}
    }
  },
  computed: {
    wrpCls () {
      return {
        'ant-pro-global-header-index-right': true,
        // [`ant-pro-global-header-index-${(this.isMobile || !this.topMenu) ? 'light' : this.theme}`]: true
      }
    }
  },
  mounted () {
    getUserThumbAvatar({ userName: storage.get('USERINFO').userInfo.userName.toLowerCase() }).then(res => {
      if (res.retCode === 0) {
        this.currentUser = {
          name: storage.get('USERINFO').userInfo.realName,
          userName: storage.get('USERINFO').userInfo.userName,
          imagePath: res.retObj
        }
      } else {
        this.currentUser = {
          name: storage.get('USERINFO').userInfo.realName,
          userName: storage.get('USERINFO').userInfo.userName,
          imagePath: 'https://gw.alipayobjects.com/zos/antfincdn/XAosXuNZyF/BiazfanxmamNRoxxVxka.png'
        }
      }
    })
  },
  methods: {
    show () {
      this.$refs.departSelect.show()
    },
    handleLogout (e) {
      Modal.confirm({
        title: '是否确定退出',
        onOk: () => {
          logout().then(res => {
            return this.$store.dispatch('Logout')
          })
        },
        onCancel () {
        }
      })
    }
  }
}
</script>
